package com.example.a2306_shop.minefg

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.a2306_shop.R
import com.example.a2306_shop.adapter.OrderAdapter
import com.example.a2306_shop.databinding.FragmentPayingBinding
import com.example.a2306_shop.databinding.FragmentWaitBinding
import com.example.lib_base.mvvm.BaseFragment

// TODO: Rename parameter arguments, choose names that match

class WaitFragment : BaseFragment<FragmentWaitBinding, OrderViewModel>() {
    lateinit var orderAdapter: OrderAdapter
    override fun initData() {
        viewModel.orderSuccess.observe(this){
            if(it.code==200){
                orderAdapter.data.clear()
                orderAdapter.data.addAll(it.data.list)
                orderAdapter.notifyDataSetChanged()
            }
        }
    }

    override fun initView() {
        orderAdapter = OrderAdapter()
        binding.rv.adapter = orderAdapter
        binding.rv.layoutManager = LinearLayoutManager(context)

        viewModel.order("2",10,1)
    }

    override fun getViewModel(): Class<OrderViewModel>  = OrderViewModel::class.java

    override fun getLayout(): Int = R.layout.fragment_wait

}